limsSampleHandle.searchPage = function (pageType) {

    return {
        getGridParam: function () {
            var _this = this;
            var columns = limsSampleHandle.getAuditListColumns(pageType); // 入库、出库、销毁
            if (pageType === 'back') {
                columns = limsSampleHandle.getBackAuditListColumns();  // 返样
            }
            _this.param.createdByOrgId_EQ = workspace.user.ext$.loginorgid
            return {
                type: 'grid',
                id: _this.idManage.handleGridId,
                url: limsSampleHandle.baseUrl + '/queries',
                columns: columns,
                readonly: true,
                requestData: _this.param,
                onLoadSuccess: function (data) {
                    if (!Gikam.isEmpty(data)) {
                        this.activeRowByIndex(0);
                    } else {
/*                        Gikam.cleanCompData([_this.idManage.sampleGridId, _this.idManage.flowGridId]);
                        Gikam.getAsyncComp(_this.idManage.uploaderId).done(function (comp) {
                            comp.setOptions({
                                bizId: -1,
                            });
                        });*/
                    }
                },
                page: true,
                onRowActive: function (index, row) {
/*                    Gikam.getAsyncComp(_this.idManage.sampleGridId).done(function (grid) {
                        grid.refresh({
                            url: limsSampleHandle.sampleUrl + '/search/handle/' + row.id,
                        });
                    });
                    Gikam.getAsyncComp(_this.idManage.uploaderId).done(function (comp) {
                        comp.setOptions({
                            bizId: row.id,
                        });
                    });
                    Gikam.getAsyncComp(_this.idManage.flowGridId).done(function (comp) {
                        comp.refresh({
                            url: IFM_CONTEXT + '/secure/core/module/sys/bpmn-comments/queries?table=T_LIMS_SAMPLE_HANDLE&id=' + row.id
                        });
                    });*/
                },
                filterOpen: true,
                onCellClick: function (field, row) {
                    field === 'handleCode' && limsSampleHandle.loadSampleHandleDetailPage(row, pageType, 'search')
                },
            }
        },

        getSampleHandleSearchInfo: function () {
            var _this = this;
            return {
                type: 'tab',
                panels: [{
                    title: 'MODULE.BUSINESS.ORDERTASK.TAB.SAMPLE_INFO',
                    items: [{
                        type: 'grid',
                        id: _this.idManage.sampleGridId,
                        columns: limsSampleHandle.getSearchSampleListColumns(),
                        onCellClick: function (field, row) {
                            field === 'ext$.batchcode' && limsSampleHandle.loadBatchDetailPage(row);
                        },
                        onRendered: function () {
                            if (pageType !== 'enter') {
                                this.hideColumns(['sampleConcentration', 'sampleVolume', 'restCount'])
                            }
                        },
                    }]
                }, {
                    title: 'GIKAM.FILE.ATTACHMENT',
                    items: [{
                        type: 'uploader',
                        id: _this.idManage.uploaderId,
                        dbTable: 'T_LIMS_SAMPLE_HANDLE',
                        readonly: true,
                        formatterGridColumns: function (columns) {
                            return Gikam.getFormatterGridColumns(columns);
                        }
                    }]
                }, {
                    title: 'T_CORE_FILE.OPERATE.OPERATION.RECORD',
                    items: [{
                        type: 'grid',
                        id: _this.idManage.flowGridId,
                        columns: limsSampleHandle.getFlowListColumns()
                    }]
                }]
            }
        },

        idManage: {
            handleGridId: pageType + 'lims-sample-handle-search-list-grid',
            sampleGridId: pageType + 'lims-handle-sample-search-list-grid',
            uploaderId: pageType + 'sample-handle-search-uploader',
            flowGridId: pageType + 'handle-flow-search-list-grid',
        },

        create: function () {
            var _this = this;
            Gikam.create('layout', {
                id: pageType + 'lims-sample-handle-search-list-layout',
                renderTo: workspace.window.$dom,
                center: {
                    items: [this.getGridParam()]
                }
/*                north: {
                    height: '40%',
                    items: [this.getGridParam()]
                },
                center: {
                    items: [this.getSampleHandleSearchInfo()]
                }*/
            });
        },

        init: function (param) {
            this.param = param;
            this.create();
        }
    }
};
